define(['./../initial', './../model/User', './../service/highchartTheme', './../service/chartFactory', './../controller/notice/notice.infoCtrl', './../controller/notice/notice.reviewCtrl', './../model/Project', './../service/showMsg', './../service/showInfoModal', './../controller/notice/notice.review.detailCtrl'], function() {
    var app = angular.module('App.home');
    app.config(['$stateProvider', '$urlRouterProvider', '$locationProvider',
        function($stateProvider, $urlRouterProvider, $locationProvider) {

            $urlRouterProvider.when('/notice', ['$stateParams', '$state', function($stateParams, $state) {
                $state.go('notice.review');
            }]);

            $stateProvider
                .state('notice', {
                    url: "/notice",
                    templateUrl: "/partials/notice/notice"
                })
                .state('notice.info', {
                    url: "/info",
                    resolve: {
                        applierList: ['User', function(User) {
                            var user = new User();
                            return user.getAppliers();
                        }],
                        Project: 'Project',
                        showMsg: 'showMsg'
                    },
                    templateUrl: "/partials/notice/notice/info",
                    controller: 'notice.infoCtrl'
                })
                .state('notice.review', {
                    url: "/review",
                    templateUrl: "/partials/notice/notice/review",
                    resolve: {
                        reviewProjectList: ['User', function(User) {
                            var user = new User();
                            return user.getReviewProjectList();
                        }],
                        Project: 'Project',
                        showMsg: 'showMsg'
                    },
                    controller: 'notice.reviewCtrl'
                })
                .state('notice.review.detail', {
                    url: "/{uid:[0-9]+}",
                    resolve: {
                        curReview: ['reviewProjectList', '$stateParams', '$state', function(reviewProjectList, $stateParams, $state) {
                            //获取当前要审核的项目
                            var cur = reviewProjectList.filter(function(item, index) {
                                return index === ($stateParams.uid - 0);
                            })[0];
                            if (!cur) {
                                $state.go('notice.review');
                            }
                            return cur;
                        }],
                        Project: 'Project',
                        chartFactory: 'chartFactory',
                        showMsg: 'showMsg',
                        showInfoModal: 'showInfoModal'
                    },
                    controller: 'notice.review.detailCtrl',
                    templateUrl: "/partials/notice/notice/review/detail"
                });
        }
    ]);
});
